package ljl.alg.wangzheng_camp.round1.stack_and_queue;

import java.util.LinkedList;

/**
 * 没啥意思 太简单
 * */
public class _155_min_stack {
    
    class MinStack {
        LinkedList<Integer> stack = new LinkedList<>();
        LinkedList<Integer> min = new LinkedList<>();
        public void push(int val) {
            stack.push(val);
            if (min.isEmpty() || min.peek() >= val) {
                min.push(val);
            }
        }
        
        public void pop() {
            int val = stack.pop();
            if (!min.isEmpty() && min.peek() == val)
                min.pop();
        }
        
        public int top() {
            return stack.peek();
        }
        
        public int getMin() {
            return min.peek();
        }
    }
}
